
#include <cstdio>
#include <BUdpSocket>
#include "member_BSocket.h"
#include "member_BUdpSocket.h"

using namespace BWE;

#define member					(*(member_BUdpSocket*)_ptr)
#define member_allocate()		_ptr = new member_BUdpSocket
#define member_release()		delete (member_BUdpSocket*)_ptr

#ifdef _LINUX_
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>

BUdpSocket::BUdpSocket()
{
	member_allocate();
	socket_member(this)->socket = ::socket(AF_INET, SOCK_DGRAM, 0);
}
BUdpSocket::~BUdpSocket()
{
	member_release();
}

BUdpSocket::Type BUdpSocket::type() const
{
	return Type_UdpSocket;
}

bool BUdpSocket::sendTo(const char* data, int length)
{
	//::sendto(pmember->socket, data, length, 0, 0, 0);
	return true;
}
bool BUdpSocket::recvFrom(char* data, int& length)
{
	//::recvfrom(pmember->socket, data, length, 0, 0, 0);
	return true;
}

#endif

#ifdef _WINDOWS_SYSTEM_

BUdpSocket::BUdpSocket()
{
	member_allocate();
	socket_member(this)->sock = ::socket(AF_INET, SOCK_DGRAM, 0);
}
BUdpSocket::~BUdpSocket()
{
	member_release();
}

BUdpSocket::Type BUdpSocket::type() const
{
	return UdpSocket;
}

bool BUdpSocket::sendTo(const char* data, int length)
{
	//::sendto(pmember->socket, data, length, 0, 0, 0);
	return true;
}
bool BUdpSocket::recvFrom(char* data, int& length)
{
	//::recvfrom(pmember->socket, data, length, 0, 0, 0);
	return true;
}

#endif
